#!/bin/bash

# New Download Dialog

LINK=$(zenity --entry --title="New Download" --width=400 --text="Enter Download Link :" --entry-text="Test Link")

if [[ "$LINK" = "" ]]; then exit 0
elif [[ "$LINK" = "Test Link" ]]; then LINK="https://androidnetworktester.googlecode.com/files/1mb.txt"
fi

ping -c 1 www.google.com &
sleep 4
pkill ping
if [ $? = 0 ];
    then    zenity --error --text=" NO Network Connection  :(" &
            exit 1
fi

aria2c --summary-interval=1 "$LINK" > .Down.log &
rm -f .D.tmp
./filter &
./progress "$LINK"

# Remove redundant log files 
# rm -f .Down.log .D.tmp
